package com.base.study04_collection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * ClassName: demo01
 * PackageName: com.cwy.study04_collection
 * Describe:
 *
 * @author: Cheng Wenying
 * @Create: 2024/1/15
 * @version:
 */
public class ToMap {
    public static void main(String[] args) {
        HashMap<String, String> map1 = new HashMap<>();
        map1.put("id", "123456");
        map1.put("bv_id", "151618153151");
        HashMap<String, String> map2 = new HashMap<>();
        map2.put("id", "1235");
        map2.put("bv_id", "151618153151");
        ArrayList<Map<String, String>> list = new ArrayList<>();
        list.add(map1);
        list.add(map2);
        Map<String, Map<String, String>> mapNew = list.stream().collect(Collectors.toMap(data -> data.get("id"), Function.identity()));
        mapNew.forEach((key,value) -> {
            System.out.println(key + "," + value);
        });
    }
}
